/*
 * ChartPanel.hpp
 *
 * Copyright 2012 Pieter Agten
 *
 * This file is part of tltgen.
 *
 * tltgen is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * tltgen is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with tltgen.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @file   ChartPanel.hpp
 * @author Pieter Agten (pieter.agten@gmail.com)
 * @date   2 nov 2012
 */

#ifndef CHARTPANEL_HPP
#define CHARTPANEL_HPP

#include <wx/wx.h>
#include <wx/spinctrl.h>
#include <boost/shared_ptr.hpp>

#include "TltPlotMouseEvent.hpp"

#include "Plot.hpp"

using boost::shared_ptr;

namespace tltgen {

  class TltPlotWindow;
  class ChartZoomPanel;
  class ChartPanel : public wxPanel {
  public:
    ChartPanel(wxWindow* parent, wxWindowID id, const shared_ptr<Plot>& plot, const wxPoint& pos, const wxSize& size);
    virtual ~ChartPanel();

  protected:
    wxPanel* createPropertiesPanel(wxWindow* parent);
    wxPanel* createCheckBoxPanel(wxWindow* parent);

    DECLARE_EVENT_TABLE();

    void addCheckBox(unsigned int i);
    void removeCheckBox(unsigned int i);

    void onPlotWindowMouseMotion(TltPlotMouseEvent& event);
    void onPlotDataChanged();
    void onPlotNbDatasetsChanged(Plot::NbDatasetsChangedEvent e, unsigned int index);
    void onGraphSelectionChange(wxCommandEvent& event);

    void onVerticalStartChanged(wxCommandEvent& event);
    void onVerticalEndChanged(wxCommandEvent& event);
    void onHorizontalStartChanged(wxCommandEvent& event);
    void onHorizontalEndChanged(wxCommandEvent& event);

    void drawPlot();

    wxPLplotwindow* getPlotWindow() const;
    wxCheckBox* getCheckBox(unsigned int i) const;

  private:
    TltPlotWindow* plotWindow;
    wxPanel* checkBoxPanel;
    ChartZoomPanel* chartZoomPanel;
    std::vector<wxCheckBox*> checkBoxes;
    std::vector<wxStaticText*> checkBoxLabels;
    shared_ptr<Plot> plot;
    wxStatusBar* statusBar;
  };

  enum {
    ID_PlotWindow = 1,
    ID_ChartZoomPanel,
  };


}

#endif


